package demo4_runnable;

public class Main {
    public static void main(String[] args) {
        //使用匿名内部类创建Runnable的实现类
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("匿名runnable实现类中的run方法正在执行");
                }
            }
        }
        );
        thread.start();
        while (true){
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("Main方法正在执行");
            }
        }
    }
}
